package com.xsomnus.java_basic.stream;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;

/**
 * @author 叶小夏
 * @since 2019-09-03 09:26
 */
public class Java8StreamTest {

    public static void main(String[] args) {
        List<Integer> arr1 = Arrays.asList(2, 4);
        List<Integer> arr2 = Arrays.asList(1, 3, 5);

        List<List<Integer>> target = Arrays.asList(arr1, arr2);
        int sum = target.stream()
                .flatMap(Collection::stream)
                .mapToInt(Integer::intValue)
                .sum();
        System.out.println(sum);
    }
}
